<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="../style/journal.css" type="text/css" />
<style type="text/css"><!--
.googleadsense {
	margin: 2px;
	padding: 0px;
//--></style><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-65008-1";
urchinTracker();
</script><title>WWW::Mechanize && Google Group</title>
</head>
<body>
<a href="index.html">Journal</a>(2005) | <a href="../blog/"><b>Blog</b></a>(2006) | <a href="http://www.fayland.org/cgi-bin/random_link.pl">RandomLink</a> | <a href="AboutFayland.html">WhoAmI</a> | <a href="LiveBookmark.html">LiveBookmark</a> | <a href="http://www.fayland.org/">HomePage</a>
<p><&lt;Previous: <a href="Profiling.html">从细节处提升Perl性能</a>&nbsp;&nbsp;>>Next: <a href="textile.html">Text::Textile</a></p>
<h1>WWW::Mechanize && Google Group</h1>
<div class='content'>
<p>Category: <a href='Modules.html'>Modules</a> &nbsp; Keywords: <b>Google Group WWW::Mechanize</b></p>觉得 Google 的 new <a href='http://groups-beta.google.com/'>新闻组</a>挺不错的，就申请了一个。<a href='http://groups-beta.google.com/group/fayland'>http://groups-beta.google.com/group/fayland</a><br>
 拿来做什么还不知道，呵呵。暂时就打算去发表自己的 <a href='index.html'>journal</a>.<p>

如果每次都登陆然后发表就太麻烦了。于是就想着用 WWW::Mechanize 来解决，然后做个 Eplanet 的功能，一键就发表了。简单写了下，挺简单的。5分种就搞定了。（终于发现自己 Perl 水平上去了，不容易呀。）<p>

简单的代码如下，具体的 Eplanet 功能还要考虑将 HTML 转换为文本形式，迟点再搞：
<pre><code>use strict;
use warnings;
use WWW::Mechanize;

my $mech = WWW::Mechanize->new( autocheck => 1 );

# first, we should login
$mech->get('https://www.google.com/accounts/Login?hl=en&cd=US&service=groups2&continue=http:%2F%2Fgroups-beta.google.com%2Fgroup%2Ffayland%2Fpost');

$mech->submit_form(
 &nbsp; &nbsp;fields   => {
 &nbsp; &nbsp; &nbsp; &nbsp;Email => 'xxx@gmail.com', # your email, google account
 &nbsp; &nbsp; &nbsp; &nbsp;Passwd => 'yyy', # your password, please not be 'yyy'
 &nbsp; &nbsp;}
);

$mech->get('http://groups-beta.google.com/group/fayland/post');

$mech->submit_form(
 &nbsp; &nbsp;fields   => {
 &nbsp; &nbsp; &nbsp; &nbsp;subject => 'Test from WWW::Mechanize',
 &nbsp; &nbsp; &nbsp; &nbsp;body => 'Yap, WWW::Mechanize it',
 &nbsp; &nbsp;},
 &nbsp; &nbsp;button => 'Action.Post'
);
</code></pre></div>
<p><&lt;Previous: <a href="Profiling.html">从细节处提升Perl性能</a>&nbsp;&nbsp;>>Next: <a href="textile.html">Text::Textile</a></p>
<p><strong>Options:</strong> <a href='http://del.icio.us/post?title=WWW::Mechanize%20&&%20Google%20Group&url=http://www.fayland.org/journal/GoogleGroup.html'>+Del.icio.us</a></p>
<strong>Related items</strong>
<ul><li><a href='050528.html'>Google Print</a> < <span class='digit'>2005-05-28 14:50:57</span> ></li><li><a href='google_sitemap.html'>Google Sitemap</a> < <span class='digit'>2005-06-04 22:52:44</span> ></li><li><a href='NewsGroup.html'>我的新闻组设置过程</a> < <span class='digit'>2004-10-30 19:12:46</span> ></li></ul>
Created on <span class="digit">2005-04-13 18:49:43</span><br />
Copyright 2004-2005 All Rights Reserved. Powered by <a href="Eplanet.html">Eplanet</a> && <a href='http://catalyst.perl.org'>Catalyst</a> 5.62.
</body>
</html>